
<table cellpadding="5" cellspacing="5" width="700px" style="border: 1px double black;">
    <thead>
    <td align="center">Dispatch</td>
    <td align="center">Customer Number</td>
    <td align="center">Location Number</td>
    </thead>
    <tr>
        <td width="200px" align="center" style="border-bottom: 2px double black;"><?php echo $model->dispatch; ?></td>
        <td width="250px" align="center" style="border-bottom: 2px double black;"><?php echo CHtml::link($model->custno,array('/customerportal')); ?></td>
        <?php 
        $location = Locations::model()->findByAttributes(array(
            'custno' => $model->custno,
            'locno'=>$model->locno
        ));
        ?>
        <td width="150px" style="border-bottom: 2px double black;" align="center"> <?php echo CHtml::link($model->locno,array('/customerportal/Locations/update','id'=>$location->id)); ?></td>
    </tr>
    <tr>
        <td align="center">
            <b>Customer/Location</b> <br>

            <?=$model->customer->firstname;?><?=$model->customer->lastname;?><br>
            <?=$model->Location->locname;?><br>
            <?=$model->Location->add1;?><br>
            <?=$model->Location->city;?>
            <?=$model->Location->zip;?>
            <?=$model->Location->state;?>

        </td>
        <td align="center"> <?php
            $errorFlag = false;

            $tech = $model->lastestTech;
            if (empty($tech)) {
                $errorFlag = true;
            } else {
                $employee = Employees::model()->findByPk($tech->empno);
                if (empty($employee)) $errorFlag = true;
            }
            ?>
            <?php
            if ($errorFlag):
                ?>
                <h2>No Data Found</h2>
                <?php
            else:
                ?>
                QSI Engineer<br>
                <img height="100px" width="100px" style="border: 1px double black;" alt="image"
                     src="/<?=$employee->image ? 'images/content/'.$employee->image  : Yii::app()->params->noImage;?>"/>  <br>
                <?php echo "$employee->firstname $employee->lastname" ?> <br>
                <?php echo $employee->workcell; ?>
                <?php endif; ?>
        </td>
        <td align="left">
            <b>Date Received</b> <?php
            $date = explode(' ', $model->receiveddate);
            echo $date['0']?><br/>
            <b>Time Received</b>  <?=$model->receivedtime?> <br/>
            <b>Called in By</b>  <?=$model->calledinby?><br/>
            <b>Received By</b>  <?php
            $emp = Employees::model()->find("pemail='$model->receivedby'");
            if (isset($emp))
                echo Employees::getEmployeeName($emp->empno);
            ?> <br/>
            <b>Status</b>     <?php
            if (!empty($model->lastestTech->status)) echo $model->lastestTech->status;
            ?> <br/>
            <b>Department</b>
            <?=$model->department?>

        </td>
    </tr>
</table>
<br>
<h1>Dispatch Notes</h1>
<br/>
<pre>
<?= $model->notes ?>
</pre>
